package ge.basicActors;

import ge.engine.Camera;
import ge.engine.Positionable;
import ge.engine.PositionableArea;

public class FollowCamera extends Camera 
{

	private Positionable followedElement;
	private double w,h;
	/**
	 * 
	 * @param element   Element who be followed by the camara, always shown in the center
	 */
	public FollowCamera(PositionableArea element)
	{
		super();
		followedElement = element;
		w = this.getWidth()/2 - element.getWidth()/2;
		h = this.getHeight()/2 - element.getHeight()/2;
	}
	
	public void update()
	{
		super.update();
		this.setPos(followedElement.getX()-w, followedElement.getY()-h);
		
	}
}
